<template>
	<view>
		<view class="mainpadding ffffff">
			<view class="flexbetween pdl" :class="index==0?'':'margin_top'" v-for="(item,index) in groupPerson" :key="item.id">
				<view class="flexleft">
					<image :src="item.avatar" style="width: 100rpx;height: 100rpx;" class="radius margin_right" mode=""></image>
					<view class="xiaohei main_size">{{item.username}}
					<text v-if="item.isqz==1">(群主)</text></view>
				</view>
				<view class="flexleft" @click="removeitem(item)" v-if="item.isqz!=1">
					<u-icon name="minus-circle-fill" color="#ff0000" size="28"></u-icon>
				</view>
			</view>
		</view>
		<moDal :message="modal" @modalSure="modalSure" @modalcancel="modalcancel"></moDal>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				modal:{
					modalShow:false,
					title:"是否确认将当前用户移除群聊？",
				},
				groupPerson: [],
				group_id: "",
				currentid:""
			}
		},
		onLoad(options) {
			this.group_id = options.id
			this.getgroupPerson()
		},
		methods: {
			removeitem(item){
				this.currentid = item.id
				this.modal.modalShow = true
			},
			getgroupPerson() {
				httpRequest.request('/webim/groups_user/members', 'GET', {
					id: this.group_id,
				}).then(res => {
					this.groupPerson = res.data.list
				})
			},
			modalSure(){
				if(this.modal.title=="是否确认将当前用户移除群聊？"){
					httpRequest.request('/webim/groups_user/tcyGroup', 'GET', {
						groupid: this.group_id,
						user_id:this.currentid
					}).then(res => {
						httpRequest.toast(res.msg)
						if(res.code==1){
							this.getgroupPerson()
						}
					})
				}
				this.modalcancel()
			},
			modalcancel(){
				this.modal.modalShow = false
			},
		}
	}
</script>

<style lang="scss" scoped>

</style>
